package com.example.administrator.szb.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.example.administrator.szb.R;

import java.util.HashMap;

import com.example.administrator.szb.activity.base.BaseActivity;
import com.example.administrator.szb.bean.GWXQBean;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.example.administrator.szb.tinkerutil.SampleApplicationLike;
import com.example.administrator.szb.http.HttpUtil;
import com.example.administrator.szb.http.URLAddress;

/**
 * Created by D N on 2017/10/18.
 */

public class JGGLYESActivity extends BaseActivity {
    @Bind(R.id.jggl_yes_bsfh)
    ImageView jgglYesBsfh;
    @Bind(R.id.jggl_yes_jfsm)
    TextView jgglYesJfsm;
    @Bind(R.id.textView113)
    TextView textView113;
    @Bind(R.id.textView116)
    TextView textView116;
    @Bind(R.id.textView119)
    TextView textView119;
    @Bind(R.id.textView122)
    TextView textView122;
    @Bind(R.id.textView125)
    TextView textView125;
    private TextView jiancheng;
    public static GWXQBean gwxqBean;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.jggl_yes_activity);
        ButterKnife.bind(this);
        SampleApplicationLike.getActivitiesInstance().add(this);
        jiancheng = (TextView) findViewById(R.id.jiancheng);
        requestData();
    }

    private void requestData() {
        HashMap<String,String> map = new HashMap<>();
        map.put("code", HttpUtil.getParam());
        map.put("users_id",SampleApplicationLike.getUserloginInstance().getId()+"");
        String url = URLAddress.URLBASE + URLAddress.URL_GWJGXQ;
        HttpUtil.RequestGsonPost(SampleApplicationLike.getQueueInstance(), Request.Method.POST, GWXQBean.class, url, map, new Response.Listener() {
            @Override
            public void onResponse(Object response) {
                gwxqBean = (GWXQBean) response;
                if (gwxqBean.getResult() == 1){
                    initView();
                }
            }


        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
    }

    private void initView() {
        textView113.setText(gwxqBean.getData().getCompany());
        textView116.setText(gwxqBean.getData().getWork_tel());
        textView119.setText(gwxqBean.getData().getCity_id());
        if (gwxqBean.getData().getJigou_introduce()!=null)
        textView122.setText(gwxqBean.getData().getJigou_introduce());
        if (gwxqBean.getData().getYewu_introduce()!=null)
        textView125.setText(gwxqBean.getData().getYewu_introduce());
        jiancheng.setText(gwxqBean.getData().getIntro());
    }

    @OnClick({R.id.jggl_yes_bsfh, R.id.jggl_yes_jfsm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.jggl_yes_bsfh:
                finish();
                break;
            case R.id.jggl_yes_jfsm:
                startActivity(new Intent(this,JGGLNOActivity.class));
                break;
        }
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        requestData();
    }
}
